package com.xiaoyu.lanling.feature.chat.model.message

import `in`.srain.cube.util.TimeUtils
import android.text.TextUtils
import com.xiaoyu.base.app.AppContext
import com.xiaoyu.im.datamodel.AppMessage
import com.xiaoyu.lanling.R
import com.xiaoyu.lanling.feature.chat.viewholder.ChatViewHolderManager

class ChatMessageSendCallItem(message: AppMessage) : ChatMessageSendBaseItem(message) {

    val attrs = message.payload.attrsCopy
    val type: String = attrs.optString("type")
    val callDuration: Long = attrs.optLong("callDuration")
    var title: String = if (TextUtils.equals(type, "cancel")) {
        AppContext.getString(R.string.chat_message_call_cancel)
    } else if (TextUtils.equals(type, "reject")) {
        AppContext.getString(R.string.chat_message_call_reject)
    } else {
        AppContext.getString(R.string.chat_message_call_duration, TimeUtils.secondsToClockText(callDuration))
    }

    override val childrenViewType: Int
        get() = ChatViewHolderManager.TYPE_SEND_CALL
}